<template>
  <div class="home-banner">
    <!-- 轮播图组件 -->
    <XtxSlider :data="sliders" isAutoPlay />
  </div>
</template>

<script>
import { ref, onMounted } from 'vue'
import { findBanner } from '@/api/home'
// 获取轮播图数据
function useBanner () {
  const sliders = ref([
    // {
    //   hrefUrl: '/#/',
    //   id: '630000201807155635',
    //   imgUrl: 'http://zhoushugang.gitee.io/erabbit-client-pc-static/images/b1.jpg'
    // },
    // {
    //   hrefUrl: '/#/',
    //   id: '650000201207058528',
    //   imgUrl: 'http://zhoushugang.gitee.io/erabbit-client-pc-static/images/b2.jpg'
    // }
  ])
  const getBannerList = async () => {
    const { result } = await findBanner()
    // console.log(result)
    sliders.value = result
  }
  onMounted(() => {
    getBannerList()
  })
  return { sliders }
}
export default {
  name: 'HomeBanner',
  setup () {
    const { sliders } = useBanner()
    return { sliders }
  }
}
</script>

<style scoped lang='less'>
.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;
}
</style>
